﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using RanchBuddy.Core.Domain;
using RanchBuddy.Core.Domain.Impl;
using StructureMap;

namespace RanchBuddy.Core.DataAccess.Impl
{
    [Pluggable("Default")]
    public class PostalCodeRepository : IPostalCodeRepository
    {
        public MapPoint GetLatLongByZip(int ZipCode)
        {
            MapPoint result = new MapPoint();
            using (RanchBuddyDataContext dc = ObjectFactory.GetInstance<IConnection>().GetLsContext())
            {
                PostalCode pc = dc.PostalCodes.Where(p => p.ZipCode == ZipCode.ToString()).FirstOrDefault();
                result.Latitude = pc.Latitude;
                result.Longitude = pc.Longitude;
            }
            return result;
        }
    }
    public struct MapPoint
    {
        public float Latitude { get; set; }
        public float Longitude { get; set; }
    }
}
